#include<iostream>
using namespace std;
typedef long long LL;
LL a, b;
LL fun(LL a, LL b)
{
	LL ans = 0;
	while (b) {
		if (b & 1) {
			ans += a;
		}
		b >>= 1;
		a = a + a;
	}
	return ans;
}
int main()
{
	while (cin >> a >> b) {
		LL res = fun(a, b);
		cout << res << endl;
	}
	return 0;
}